/**
 * 
 */
package org.mythflow.activity;

import android.content.Context;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.util.Log;

/**
 * @author dmfrey
 *
 */
public class Preferences extends PreferenceActivity {

	private static final String TAG = "Preferences";
	
	public static final String ADDRESS = "address";
	public static final String ADDRESS_DEFAULT = "192.168.10.200";
	public static final String WEB_PORT = "web_port";
	public static final String WEB_PORT_DEFAULT = "8080";
	public static final String MYTHWEB_CONTEXT = "mythweb_context";
	public static final String MYTHWEB_CONTEXT_DEFAULT = "mythweb";
	public static final String MYTHWEB_USERNAME = "mythweb_username";
	public static final String MYTHWEB_USERNAME_DEFAULT = "";
	public static final String MYTHWEB_PASSWORD = "mythweb_password";
	public static final String MYTHWEB_PASSWORD_DEFAULT = "";
	
	@Override
	protected void onCreate( Bundle savedInstanceState ) {
		super.onCreate( savedInstanceState );
		Log.i( TAG, "onCreate : enter" );
		
		addPreferencesFromResource( R.xml.settings );

		Log.i( TAG, "onCreate : exit" );
	}

	public static String getAddress( Context context ) {
		Log.d( TAG, "getAddress : enter" );
		Log.d( TAG, "getAddress : exit" );
		return PreferenceManager.getDefaultSharedPreferences( context )
								.getString( ADDRESS, ADDRESS_DEFAULT );
	}
	
	public static String getWebPort( Context context ) {
		Log.d( TAG, "getWebPort : enter" );
		Log.d( TAG, "getWebPort : exit" );
		return PreferenceManager.getDefaultSharedPreferences( context )
								.getString( WEB_PORT, WEB_PORT_DEFAULT );
	}

	public static String getMythwebContext( Context context ) {
		Log.d( TAG, "getMythwebContext : enter" );
		Log.d( TAG, "getMythwebContext : exit" );
		return PreferenceManager.getDefaultSharedPreferences( context )
								.getString( MYTHWEB_CONTEXT, MYTHWEB_CONTEXT_DEFAULT );
	}

	public static String getMythwebUsername( Context context ) {
		Log.d( TAG, "getMythwebUsername : enter" );
		Log.d( TAG, "getMythwebUsername : exit" );
		return PreferenceManager.getDefaultSharedPreferences( context )
								.getString( MYTHWEB_USERNAME, MYTHWEB_USERNAME_DEFAULT );
	}

	public static String getMythwebPassword( Context context ) {
		Log.d( TAG, "getMythwebPassword : enter" );
		Log.d( TAG, "getMythwebPassword : exit" );
		return PreferenceManager.getDefaultSharedPreferences( context )
								.getString( MYTHWEB_PASSWORD, MYTHWEB_PASSWORD_DEFAULT );
	}

}
